#pragma once

#include <QObject>
#include <qsqldatabase.h>

class UseMySQL : public QObject
{
	Q_OBJECT

public:
	UseMySQL(QObject *parent = nullptr);
	~UseMySQL();

	static UseMySQL* instance();

	QString getDepartmentId(const QString& name);
	bool getDepartmentInfo(const QString& id, QStringList& fields, QVector<QVector<QString>>& info);
	bool getEmployeeInfo(const QString& id, QStringList& fields, QVector<QString>& info);
	QString getDepartmentName(const QString& id);
	QString addEmployee(const QString& departmentId, const QString& employeeName, const QString& headPath);
	bool deleteEmployee(const QString& id);

private:
	bool connectMySQL();

private:
	QSqlDatabase base;
};
